<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/Model.php');
require_once($Config->SiteRoot.'Models/Voorstelling.php');
require_once($Config->WebCMSRoot.'Data/Media.php');
require_once($Config->SiteRoot.'Data/Voorstelling.php');

define('_MEDIATYPE_KRANT', 'KRANT');
define('_MEDIATYPE_AUDIO', 'AUDIO');
define('_MEDIATYPE_VIDEO', 'VIDEO');
define('_MEDIATYPE_OTHER', 'OTHER');

Class MediaModel extends BaseModel
{
	var $Titel;
	var $Bron;
	var $File;
	var $URL;
	var $Type;
	var $Size;
	var $SpecificSize;
	var $transcription;
	var $VoorstellingID;

	var $Voorstelling;

	function VoorstellingModel()
	{
		$this->Titel          = '';
		$this->Bron           = '';
		$this->File           = '';
		$this->URL            = '';
		$this->Type           = _MEDIATYPE_OTHER;
		$this->Size           = '';
		$this->SpecificSize   = '';
		$this->Transcription  = '';
		$this->VoorstellingID = 0;
		
		parent::BaseModel();
	}
	
	function Retrieve(&$parameters)
	{
		$db = new MediaData();
		$this->Parameters = &$parameters;
		
		$this->ID   		      = $this->GetParameter('id');
		$this->Titel 		      = $this->GetParameter('titel');
		$this->Bron           = $this->GetParameter('bron');
		$this->File 		      = $this->GetParameter('file');
		$this->URL 		  	    = $this->GetParameter('url');
		$this->Type  		      = $this->GetParameter('type');
		$this->Size 		      = $this->GetParameter('size');
		$this->SpecificSize   = $this->GetParameter('specificSize');
		$this->Transcription  = $this->GetParameter('transcription');
		$this->VoorstellingID = $this->GetParameter('voorstellingID');
		
		if ($this->ParameterExists('jaar'))
		{
			$this->Voorstelling = new VoorstellingModel();
			$this->Voorstelling->Jaar = $this->GetParameter('jaar');
			
			$voorstellingDb = new VoorstellingData();
			$voorstelling = $voorstellingDb->Retrieve(&$this->Voorstelling);
			
			$this->VoorstellingID = -1;
			if (count($this->Voorstelling->Collection) > 0)
			{
				$this->VoorstellingID = $this->Voorstelling->Collection[0]->ID;
			}
		}
		
		$db->Retrieve(&$this);
	}
}
?>